#!/bin/bash

#SBATCH -J damask
#SBATCH -N 1
#SBATCH --ntasks-per-node 32
#SBATCH -p normal
#SBATCH -o damask-%j.log
#SBATCH -e damask-%j.err
#SBATCH --comment=WRF

export petscVersion=v3.15.5
source ~/.bashrc
sev
if [[ $DAMASK_ROOT == 0 ]]; then
    export DAMASK_ROOT=${HOME}/DWei/damask
fi
source ${DAMASK_ROOT}/env/DAMASK.sh
exeDir=${DAMASK_ROOT}/build/grid/
exeName=DAMASK_grid
exePath=${exeDir}/${exeName}
if [[ ! -f $exePath ]]; then
    exePath=`which DAMASK_grid`
fi
export PATH=$exeDir:$PATH
export MKL_NUM_THREADS=1
export OMP_NUM_THREADS=1

#unset MPIHOME
#unset LD_LIBRARY_PATH

ulimit -c unlimited

hostfile=hostfile.${SLURM_JOB_ID}
srun hostname -s | sort -n > $hostfile
cat $hostfile
ncpu=`srun hostname -s | wc -l`
echo "ncpu=$ncpu"

echo "JobFileName=$0"
MPIRUN_EXE=`which mpirun`

#mpirun -n ${ncpus} -machinefile $hostfile ${exe} ./$ctrlFile
MPIRUN_EXE=$(which mpirun)
$MPIRUN_EXE -np $ncpu -machinefile $hostfile $exePath --help

rm -f ${hostfile}

